package com.smh.a03exerciseDemo1;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Arrays;

public class Test6 {
    public static void main(String[] args) throws IOException {

        FileReader fr = new FileReader("day26-code\\file\\d.txt");

        FileWriter fw = new FileWriter("day26-code\\file\\e.txt");

        char[] chars = new char[1024 * 1024];
        int len;
        StringBuilder sb = new StringBuilder();
        while ((len = fr.read(chars)) != -1) {
            sb.append(chars, 0, len);
//            for (char aChar : chars) {
//                sb.append(aChar);
//            }
        }

        Integer[] array = Arrays.stream(sb.toString().split("-"))
                .map(s -> Integer.parseInt(s))
                .sorted()
                .toArray(Integer[]::new);
        String replace = array.toString().replace(',', '-');
        String substring = replace.substring(1, replace.length() - 1);

        fw.write(substring);
        fw.close();
        fr.close();


    }
}
